package com.handtransaction.service.impl;

import com.handtransaction.dao.CategoryDao;
import com.handtransaction.entity.Category;
import com.handtransaction.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryImpl implements CategoryService {
    @Autowired
    private CategoryDao categoryDao;

    /**
     * 管理员对类别的增删改查操作
     */

    @Override
    public int addCategory(String cname) {
        int cid=categoryDao.queryAllCategory().size()+1;
        return categoryDao.addCategory(cid,cname);
    }
    @Override
    public int deleteCategory(Integer cid) {
        return categoryDao.deleteCategory(cid);
    }
    @Override
    public int updateCategory(Category category) {
        return categoryDao.updateCategory(category);
    }
    @Override
    public Category queryCategory(String cname) {
        return categoryDao.queryCategory(cname);
    }
    @Override
    public Category queryCategoryById(Integer cid) {
        return categoryDao.querycategoryById(cid);
    }
    @Override
    public List<Category> queryAllCategory() {
        return categoryDao.queryAllCategory();
    }

    /**
     * 首页、用户等对类别的操作
     */




}
